{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "da2a5ed8",
   "metadata": {},
   "outputs": [],
   "source": [
    "from gs_quant.instrument import IRSwaption\n",
    "from gs_quant.risk import CurveScenario, MarketDataPattern, MultiScenario\n",
    "from gs_quant.session import Environment, GsSession\n",
    "from gs_quant_internal.boltweb import valuation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "71b4f043",
   "metadata": {},
   "outputs": [],
   "source": [
    "# external users should substitute their client id and secret; please skip this step if using internal jupyterhub\n",
    "GsSession.use(Environment.PROD, client_id=None, client_secret=None, scopes=('run_analytics',))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2bf27b8b",
   "metadata": {},
   "outputs": [],
   "source": [
    "swaption = IRSwaption('Receive', '5y', 'USD', expiration_date='13m', strike='atm')\n",
    "swaption.resolve()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5956a6da",
   "metadata": {},
   "outputs": [],
   "source": [
    "original_price = swaption.price()\n",
    "market_data = swaption.market().market_data_dict\n",
    "print('Base price:     {:,.2f}'.format(original_price))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "88163749",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create multiple curve scenarios (Multi Scenario only supports a list of the same type of scenario)\n",
    "shifts = [5, 10, 15]\n",
    "list_of_scenarios = [CurveScenario(market_data_pattern=MarketDataPattern('IR', 'USD'), parallel_shift=p, \n",
    "                                   name=f\"parallel shift {p}\") for p in shifts]\n",
    "multi_scenario = MultiScenario(scenarios = list_of_scenarios)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "159cd685",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# Price the swaption under a multiple curve scenarios\n",
    "with multi_scenario:\n",
    "    scenario_price = swaption.price()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c0c69ce2",
   "metadata": {},
   "outputs": [],
   "source": [
    "scenario_price"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "946b62d3",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
